#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n = 0;
    int count = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (i % 7 == 0)
        {
            count++;
            continue;
        }
        string s;
        s += to_string(i);
        size_t pos = s.find('7');
        if (pos != string::npos)
        {
            count++;
        }
    }
    cout << count;
    return 0;
}